$(document).ready(function() {
	/*独家分页*/
	MyObjectogHHH = {
		//url : "http://127.0.0.1/app/exp/serviceListCheck",
		url:Server + "/app/exp/serviceListCheck",
		haveouId : organizationId,
		ishavename : '',
		//haveouId : 2,
		boolean : false,
		type : "POST",
		dataType : "JSON",
		number : 1,
		AllCount : 0,
		nowp : 0,
		Callback : function(nowPage, ishavasend) {
			MyObjectogHHH.nowp = nowPage;
			serviceListCheck(MyObjectogHHH.nowp-1,MyObjectogHHH.haveouId,MyObjectogHHH.ishavename);
		}
	};

	function MyObjectogHHHofpageload() {
		$("#page").initPage((function() {
			$.ajax({
				"url" : MyObjectogHHH.url,
				"type" : MyObjectogHHH.type,
				"dataType" : MyObjectogHHH.dataType,
				"async" : MyObjectogHHH.boolean,
				"data" : {
					"offset" : MyObjectogHHH.number,
					"limit" : MyObjectogHHH.number,
					"ouId" : MyObjectogHHH.haveouId,
					"name" : MyObjectogHHH.ishavename
				},
				success : function(data) {
					MyObjectogHHH.AllCount = data.total;
				}
			});
			return MyObjectogHHH.AllCount;
		})(), MyObjectogHHH.number, MyObjectogHHH.Callback);
	}
	MyObjectogHHHofpageload();

	$("#bgf").click(function() {
		MyObjectogHHH.ishavename = $("#aiya").val();
		MyObjectogHHHofpageload();
	})

})



function serviceListCheck(offset,ouId,name){
	$.ajax({
		//"url" : "http://127.0.0.1/app/exp/serviceListCheck",
		"url" : Server + "/app/exp/serviceListCheck",
		"type" : "Post",
		"dataType" : "Json",
		"data" : {
			"offset" : offset,
			"limit" : 10,
			"ouId" : ouId,
			"name" : name
		},
		success : function(data){
			
			var m = data.rows;
			var html = "";
			var item ='<tr>\
				<th>序号</th>\
				<th>名称</th>\
				<th>服务收费</th>\
				<th>服务结果获取</th>\
				<th>审核结果</th>\
				<th>操作</th>\
			    </tr>';
			var pattern = '<tr>\
								<td>#1</td>\
								<td>#2</td>\
								<td>#3</td>\
								<td>#4</td>\
								<td>#5</td>\
								<td>\
									<a onclick="serviceDetail(#6)">查看</a>\
								</td>\
							</tr>';
			for (var i = 0; i < m.length; i++){
				var num = i+1;
				//alert(num);
				var status ="";
					switch (m[i].isCheck){//是否审核(0未审核，1审核成功，2审核失败)
					case 0:
						status = "待审核";
						break;
					case 1:
						status = "审核成功";
						break;
					case 2:
						status = "审核失败";
						break;						
				 }
				
				item += pattern
				   .replace("#1", num)
	               .replace("#2", m[i].serviceName)
	               .replace("#3", m[i].serviceFee)
	               .replace("#4", m[i].getTime + "天")
	               .replace("#5", status)
	               .replace("#6", m[i].serviceId)
			}
			$("#serviceList").html(item);
		}
	})
}

function serviceDetail(id) {
	$(location).attr('href', 'new2new2_add2add2?serviceId=' + id + '');
}

